import { delCache } from "#server/utils/context"; import { deleteCategory, getCategoryById } from "../../service/category"; export default defineWrappedResponseHandler(async (event) => { const id = getRouterParam(event, "id"); if (!id) return R.throwError(400, "缺少分类 ID", null); const existing = await getCategoryById(id); if (!existing) return R.throwError(404, "分类不存在", null); await deleteCategory(id); await delCache(`category:${id}`); await delCache("categories:tree"); return R.success(null); });